package com.vrv.vap.server.controller;

import com.vrv.vap.server.entity.User;
import com.vrv.vap.server.service.UserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2021-06-24 17:26:12
 */
@RestController
@RequestMapping("user")
public class UserController {
    /**
     * 服务对象
     */
    @Resource
    private UserService userService;

    /**
     * 通过主键查询单条数据
     * 有权限访问
     * @param id 主键
     * @return 单条数据
     */
    @PreAuthorize("hasAuthority('admin:user:list')")
    @GetMapping("selectOne")
    public User selectOne(Integer id) {
        return this.userService.queryById(id);
    }

    /**
     *  url有权限，但是方法无权限访问
     * @return List<User>
     */
    @PreAuthorize("hasAuthority('admin:user:query')")
    @GetMapping("queryLimit")
    public List<User> queryAllByLimit() {
        return this.userService.queryAllByLimit(0,3);
    }

}